<template>
  <div class="todolist">
    <div class="container">任务列表</div>
    <div class="top">
      添加任务:
      <input
        v-model="NewItem"
        v-focus
        @keyup.enter="onSubmit"
        type="text"
        class="top-input"
        placeholder="输入任务名称，点击回车即可添加任务"
      />
    </div>
    <div class="body">
      <div class="body-left">
        <p v-for="(item, index) in list"
          :key="index"
          class="left"
          @click="changeNav(item.activeName)">
          {{ item.name }}:(0) </p>
      </div>
      <div class="body-right">
        <missions></missions>
        <component :is="active"></component>
      </div>
    </div>
  </div>
</template>

<script>
import missions from "./missions";
import unfinished from "./unfinished.vue";
import allmission from "./allmission.vue";

export default {
  name: "todo",
  components: { missions, unfinished, allmission },
  data() {
    return {
    NewItem:'',
    items:[],
      list: [
        { name: "已完成任务", activeName: "missions" },
        { name: "未完成任务", activeName: "unfinished" },
        { name: "所有任务", activeName: "allmission" },
      ],
      active: "missions",
    };
  },
  methods: {
    changeNav(name) {
      console.log("name", name);
      this.active = name;
    },
    onSubmit() {
      console.log("ipt====>",this.NewItem);
        this.items.push({
            label:this.NewItem
        });
        console.log("ipt====>",this.items[0]);
        
        this.NewItem ="";
    },
  },
};
</script>

<style lang="less">
.todolist {
  width: 1000px;
  height: 900px;
  margin: auto;
  box-shadow: 1px 0px 15px 5px #acb2af;
}
.container {
  height: 40px;
  margin: auto;
  font-size: 30px;
  text-align: center;
  background-color: #3f9cdb;
  color: #fff;
  padding-top: 0;
}
.top {
  height: 100px;
  display: flex;
  justify-content: space-around;
  align-items: center;
  font-size: 25px;
  background-color: #fafafa;
  &-input {
    width: 800px;
    height: 40px;
    border-radius: 10px;
    outline: none;
    font-size: 20px;
  cursor:pointer;
  }
}
p {
  width: 200px;
  height: 60px;
  margin-top: 20px;
  margin-left: 30px;
  background-color: #fff;
  border-radius: 20px;
}
.body {
  height: 760px;
  display: flex;
  background-color: #fafafa;
  justify-content: space-between;
  flex-wrap: nowrap;
  &-left {
    width: 30%;
    background-color: #fafafa;
    font-size: 25px;
    text-align:center;
    color: #56a9df;
    margin-right: 0;
  }
  &-right {
    width: 700px;
    height: 700px;
    background-color: #fff;
    border: 10px solid #eaeaea;
    border-radius: 50px;
    margin-right: 20px;
  }
}
input {
  text-indent: 1em;
  margin-left: 30px;
}
</style>
